<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>用户管理</title>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/frame/layui/css/layui.css">
<!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/frame/static/css/style.css">
<link rel="icon"
	href="<%=request.getContextPath()%>/frame/static/image/code.png">
</head>
<body class="body">

	<!-- 工具集 -->
	<div class="my-btn-box">
		<span class="fl"> <a
			class="layui-btn layui-btn-danger radius btn-delect"
			id="btn-delete-all" onclick="del()">批量删除</a> <a
			class="layui-btn layui-btn-danger radius btn-delect"
			id="btn-delete-all" onclick="check()">成为歌手</a> <a
			class="layui-btn btn-add btn-default" id="btn-add"
			href="<%=request.getContextPath()%>/manager/toMuserAdd">添加用户</a> <a
			class="layui-btn btn-add btn-default" id="btn-refresh"
			href="<%=request.getContextPath()%>/manager/selectSingers">审核歌手</a> <a
			class="layui-btn layui-btn-primary"
			href="<%=request.getContextPath()%>/manager/toMindex">管理员</a>
		</span>
		<form action="<%=request.getContextPath()%>/manager/selectUsers"
			method="post">
			<span class="fr"> <span class="layui-form-label">搜索：</span>
				<div class="layui-input-inline">
					<input type="text" name="userName" autocomplete="off"
						placeholder="请输入用户名" class="layui-input">
				</div>
				<button class="layui-btn mgl-20" type="submit">查询</button>
			</span>
		</form>
	</div>

	<table class="layui-table">
		<colgroup>
			<col width="150">
			<col width="150">
			<col width="200">
			<col>
		</colgroup>
		<thead>
			<tr>
				<th>删除/审核</th>
				<th>用户名</th>
				<th>真实姓名</th>
				<th>密码</th>
				<th>身份</th>
				<th>修改</th>

			</tr>

		</thead>

		<tbody>
			<c:forEach items="${userlist }" var="userlist">
				<tr>
					<td><input type="checkbox" name="userId"
						value="${userlist.userId}"></td>
					<td>${userlist.userName }</td>
					<td>${userlist.realName }</td>
					<td>${userlist.password }</td>
					<td><c:if test="${userlist.singer== 0}">普通用户</c:if> <c:if
							test="${userlist.singer== 1}">音乐人</c:if> <c:if
							test="${userlist.singer== 2}">普通用户
						</c:if></td>
					<td align="center"><a onclick="update(${userlist.userId})">修改</a></td>
				</tr>
			</c:forEach>
		</tbody>

	</table>


	<!-- 表格操作按钮集 -->
	<script type== "type/html" id="barOption">
    <a class="layui-btn layui-btn-mini" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-mini layui-btn-normal" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-mini layui-btn-danger" lay-event="del">删除</a>
</script>

	<script type="text/javascript">
	function update(userId){
		window.location.href="<%=request.getContextPath()%>/manager/toMuserUpdate?userId="+userId;
	}
	
	function del(){
		var obj = document.getElementsByName("userId");
		ids = [];
		for (k in obj) {
			if (obj[k].checked)
				ids.push(obj[k].value);
		}
		if (ids.length == 0) {
			//alert("请选择要删除的记录");
		} else {
			var flag = window.confirm("确认要删除吗？");
			if (flag) {
				window.location.href = "<%=request.getContextPath()%>/manager/deleteUsers" + "?userId=" + ids;
			}
		}
	}
	
	function check(){
		var obj = document.getElementsByName("userId");
		ids = [];
		for (k in obj) {
			if (obj[k].checked)
				ids.push(obj[k].value);
		}
		if (ids.length == 0) {
			//alert("请选择要删除的记录");
		} else {
			var flag = window.confirm("确认通过审核？");
			if (flag) {
				window.location.href = "<%=request.getContextPath()%>/manager/becomeSinger" + "?ids=" + ids;
			}
		}
	}
</script>
</body>
</html>